﻿Public Class EliminarInventarios
    Inherits System.Web.UI.Page
    Dim c As New Conexion
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("VariableNombre") = Nothing Then
            Label1.Text = "Tienes que Logearte"
            btnLogout.Visible = False
        Else
            HyperLink1.Visible = False
            Label2.Text = "Bienvenido " + Session("VariableNombre").ToString()

            c.SeleccionarLetras(TextBox6, "select nombres from usuarios where login='" & Session("VariableNombre").ToString() & "'")
            Label2.Text = "Bienvenido " + TextBox6.Text


        End If

        GridView1.DataSource = c.TablaTodoInventario()
        GridView1.DataBind()
    End Sub

    Protected Sub btnLogout_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogout.Click
        Session("VariableNombre") = Nothing
        Response.Redirect("InicioSesion.aspx")
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim nombres As String = DropDownList1.SelectedItem.Text
        c.Seleccionar(TextBox7, "select idinventario from inventario where descripcion='" & nombres & "'")
        Dim sentencia As String = "delete from descripcioninventario where idinventario='" & TextBox7.Text & "'"
        c.Insertar_Actualizar_Eliminar(sentencia, "eliminados")
        sentencia = "delete from inventario where descripcion='" & nombres & "'"
        c.Insertar_Actualizar_Eliminar(sentencia, "eliminados")
        Label1.Text = Conexion.msj_sql_server

        'Llenamos el Datagrid
        GridView1.DataSource = c.TablaTodoInventario()
        GridView1.DataBind()
    End Sub
End Class